-- 摆摊
require("TSLib")

local logger = require("logger")
local M = {}

function M.grid(row,column)
	local knapsack_column = {170, 425, 680, 930}
	local knapsack_row = {260, 443}
	return knapsack_column[column], knapsack_row[row]
end

function M.find_add_button()
	for c = 1, 4, 1 do
		for r = 1, 2, 1 do
			x, y = M.grid(r,c)
			if (isColor(x, y, 0xbc604b, 85)) then
				return x, y
			end
		end
	end
	return -1,-1
end

function M.find_have_girl(...)
	if (isColor( 386,  323, 0xc4bbdc, 85) and 
		isColor( 382,  328, 0x484183, 85) and 
		isColor( 386,  329, 0x5139e8, 85) and 
		isColor( 397,  322, 0xfce8c8, 85) and 
		isColor( 387,  308, 0xd99d89, 85) and 
		isColor( 372,  330, 0xa58aee, 85) and 
		isColor( 411,  344, 0xd6c2e2, 85) and 
		isColor( 418,  309, 0xbf6f85, 85) and 
		isColor( 404,  304, 0xd8b3fa, 85) and 
		isColor( 390,  294, 0xeea598, 85)) 
	then
		logger.debug("无其他玩家在售")
		return true
	end
	return false
end

function M.find_close_button(...)
	x = 1056
	y = 66
	if (isColor(x, y, 0xfedd90, 85)) then
		return x,y
	end
	return -1,-1
end

function main(...)
	init(1)
	--x, y = M.find_add_button()
	--logger.debug(x..","..y)
	mSleep(1000)
	
	nLog(M.find_have_girl())
	mSleep(1000)
end
main()

return M